<?php
if(isset($_GET["mod"]))	{
	$mod	=	$_GET["mod"];
}
else	{
	$mod	=	"twoball";
}

include_once("inc/lotteryMod.php");
$aMod	=	lotteryMod("lotteryMod/".$mod.".csv");
include_once("inc/sNum2aNum.php");

if(isset($_GET["num"]))	{
	$strNum	=	$_GET["num"];
	$arrSim	=	sNum2aNum($strNum,$aMod);
}
else	{
	$strNum	=	"4,11,14,17,18,27,16";
	$arrSim	=	sNum2aNum($strNum,$aMod);
}

echo '<a href="index.htm">返回</a> ';
echo '<a href="check.php?mod=twoball&num=2,3,5,8,13,21,1">双色球</a> ';
echo '<a href="check.php?mod=lotto&num=3,5,8,13,21,1,2">大乐透</a> ';
echo '<a href="check.php?mod=26s5&num=3,5,8,13,21">福彩26选5</a> ';
echo '<a href="check.php?mod=3d&num=2,3,5">福彩3D</a>';
echo "<hr />";
include_once("inc/file2history.php");
$aHistory	=	file2history("history/".$mod.".csv");
$aHistory	=	array_pop($aHistory);
include_once("inc/lotteryMod.php");
$aMod	=	lotteryMod("lotteryMod/".$mod.".csv");
$aSimBingo	=	csvSimCheck($arrSim,$aHistory,$aMod);
include_once("inc/getBingoLvl.php");
$aBingoLvl	=	getBingoLvl("bingo/".$mod.".csv");

print_r($aHistory);
echo "<br />";
print_r($arrSim);
echo "<br />";
echo bingoCheck($aSimBingo,$aBingoLvl);
?>
<?php
function csvSimCheck($arrSim,$aHistory,$aMod)	{
	$strHistory	=	implode(",",$aHistory);
	$aHistory	=	sNum2aNum($strHistory,$aMod);
	$aBingo	=	singleCheck($arrSim,$aHistory);
	return $aBingo;
}
?>
<?php
function singleCheck($aSim,$aHistory)	{
	$sector = count($aSim);
	$bingo=array();
	for($i=0;$i<$sector;$i++)	{
		$bingo[$i]=0;
	}
	foreach($aSim as $key => $sim)	{
		foreach($sim as $index=>$num)	{
			if(in_array((int)$num,$aHistory[$key]))	{
				$bingo[$key]++;
			}
		}
	}
	return $bingo;
}
?>
<?php
function bingoCheck($aSimBingo,$aBingoLvl)	{
	$level = False;
	foreach($aBingoLvl as $lvl => $singleLvl)	{
		if(in_array($aSimBingo,$singleLvl))	{
			if($level <$lvl)	{
				$level = $lvl;
			}
		}
	}
	return $level;
}
?>